package edu.westga.sketchit2009cs.tester;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import edu.westga.sketchit2009cs.gameEngine.WordListHandler;

/**
 * This tester test the WordListHandler class which creates a list from
 * a string and performs a few other functions.
 * @author RJ Hill
 *
 */
public class WordListHandlerTester {
	private WordListHandler theHandler;
	private String wordStringDefaultDelimiter;
	private String wordStringCommaDelimiter;
	private String ohWord = "oh";
	private String heyWord = "hey";
	private String whatsUpWord = "what's up";
	
	@Before
	public void SetUp() {
		theHandler = new WordListHandler();
		wordStringDefaultDelimiter = "oh:hey:what's up:bye";
		wordStringCommaDelimiter = "oh,hey,what's up,bye";
	}
	
	//============= Using default delimiter in the string =============
	
	@Test
	public void shouldGetOhWhenGetCategoryUsingDefaultDelimiter() {
		this.theHandler.createWordList(wordStringDefaultDelimiter);
		assertEquals(this.theHandler.getCategory(), ohWord);
	}
	
	@Test
	public void shouldGetHeyWhenGetCurrentWordUsingDefaultDelimiter() {
		this.theHandler.createWordList(wordStringDefaultDelimiter);
		this.theHandler.getCategory();
		assertEquals(this.theHandler.getCurrentWord(), heyWord);
	}
	
	@Test
	public void shouldBeTrueWhenNextWordExistsUsingDefaultDelimiter() {
		this.theHandler.createWordList(wordStringDefaultDelimiter);
		this.theHandler.getCategory();
		assertEquals(this.theHandler.nextWordExists(), true);
	}
	
	@Test
	public void shouldGetWhatsUpWhenNextWordUsingDefaultDelimiter() {
		this.theHandler.createWordList(wordStringDefaultDelimiter);
		this.theHandler.getCategory();
		assertEquals(this.theHandler.nextWord(), whatsUpWord);
	}
	
	//=========== Using comma as a delimiter in the string ===========
	
	@Test
	public void shouldGetShoesWhenGetCategoryUsingCommaDelimiter() {
		this.theHandler.createWordList(wordStringCommaDelimiter, ",");
		assertEquals(this.theHandler.getCategory(), ohWord);
	}
	
	@Test
	public void shouldGetAreWhenGetCurrentWordUsingCommaDelimiter() {
		this.theHandler.createWordList(wordStringCommaDelimiter, ",");
		this.theHandler.getCategory();
		assertEquals(this.theHandler.getCurrentWord(), heyWord);
	}
	
	@Test
	public void shouldBeTrueWhenNextWordExistsUsingCommaDelimiter() {
		this.theHandler.createWordList(wordStringCommaDelimiter, ",");
		this.theHandler.getCategory();
		assertEquals(this.theHandler.nextWordExists(), true);
	}
	
	@Test
	public void shouldGetNeatWhenNextWordUsingCommaDelimiter() {
		this.theHandler.createWordList(wordStringCommaDelimiter, ",");
		this.theHandler.getCategory();
		assertEquals(this.theHandler.nextWord(), whatsUpWord);
	}
}
